<?php
require("class.phpmailer.php");


if(!defined('INCLUDE_CHECK')) die('You are not allowed to execute this file directly');

function checkEmail($str)
{
	return preg_match("/^[\.A-z0-9_\-\+]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $str);
}


function send_mail($from,$to,$subject,$body)
{

$mail  = new PHPMailer();
$mail->IsSMTP();

//GMAIL config
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->SMTPSecure = "ssl";                 // sets the prefix to the server
$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
$mail->Port       = 465;                   // set the SMTP port for the GMAIL server
$mail->Username   = "vartak@gmail.com";  // GMAIL username
$mail->Password   = "chet1gmail";            // GMAIL password
//End Gmail

$mail->From       = $from;
$mail->FromName   = "Chetan";
$mail->Subject    = $subject;
$mail->MsgHTML($body);

//$mail->AddReplyTo("vartak@gmail.com","Chetan S Vartak");//they answer here, optional
$mail->AddAddress($to);
$mail->IsHTML(true); // send as HTML

//	$headers = '';
//	$headers .= "From: $from\n";
//	$headers .= "Reply-to: $from\n";
//	$headers .= "Return-Path: $from\n";
//	$headers .= "Message-ID: <" . md5(uniqid(time())) . "@" . $_SERVER['SERVER_NAME'] . ">\n";
//	$headers .= "MIME-Version: 1.0\n";
//	$headers .= "Date: " . date('r', time()) . "\n";

//	mail($to,$subject,$body,$headers);
if(!$mail->Send()) {//to see if we return a message or a value bolean
    echo "Mailer Error: " . $mail->ErrorInfo;
} else  echo "Message sent!";


}
?>